package cn.ffcs.unm.military.dao.impl;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang.StringEscapeUtils;
import org.springframework.stereotype.Repository;

import cn.ffcs.unm.military.dao.SoldierSituationDao;
import cn.ffcs.unm.military.model.MilitaryRetirement;
import cn.ffcs.uom.common.dao.BaseDaoImpl;
import cn.ffcs.uom.common.util.StrUtil;
import cn.ffcs.uom.common.vo.PageInfo;

@Repository("soldierSituationDao")
public class SoldierSituationDaoImpl extends BaseDaoImpl
		implements
			SoldierSituationDao {

	@Override
	public PageInfo queryPageInfoByMilitaryRetirement(
			MilitaryRetirement militaryRetirement, int currentPage, int pageSize) {

		StringBuilder sb = new StringBuilder();
		sb.append(" select * from VIEW_HI_PSNDOC_GLBDEF1 where 1 = 1 ");
		List<Object> params = new ArrayList<Object>();
		if (null != militaryRetirement) {
			if (!StrUtil.isEmpty(militaryRetirement.getMonthId())) {
				sb.append(" AND monthId = ? ");
				params.add(militaryRetirement.getMonthId());
			}
			if (!StrUtil.isEmpty(militaryRetirement.getPkPsndoc())) {
				sb.append(" AND pkPsndoc LIKE ? ");
				params.add("%"
						+ StringEscapeUtils.escapeSql(militaryRetirement
								.getPkPsndoc()) + "%");
			}
		}
		return this.jdbcFindPageInfo(sb.toString(), params, currentPage,
				pageSize, MilitaryRetirement.class);
	}

}
